﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NumbersDivisibleBy21
{
    class NumbersDivisibleBy21
    {
        const int divisor1 = 7;
        const int divisor2 = 3;

        static void PrintNumberDivisibleBy(int[] numbers)
        {
            var divisibleNumbers = numbers.Where(x => x % divisor1 == 0 && x % divisor2 == 0);
            foreach (var divisibleNumber in divisibleNumbers)
            {
                Console.WriteLine(divisibleNumber);
            }
        }

        static void PrintNumbersDivisibleByLINQ(int[] numbers)
        {
            var divisibleNumbers =
                from number in numbers
                where number % divisor1 == 0 && number % divisor2 == 0
                select number;
            foreach (var divisibleNumber in divisibleNumbers)
            {
                Console.WriteLine(divisibleNumber);
            }
        }

        static void Main(string[] args)
        {
            int[] numbers = { 20, 21, 22, 23, 24, 41, 42, 43, 44 };
            Console.WriteLine("By Extension Methods:");
            PrintNumberDivisibleBy(numbers);
            Console.WriteLine("By LINQ:");
            PrintNumbersDivisibleByLINQ(numbers);
        }
    }
}
